package com.kingyea.mobilepolice.config.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.util.UUID;

/**
 * <dl>
 * <dt>SendController</dt>
 * <dd>Description:</dd>
 * <dd>CreateDate: 2017/9/1</dd>
 * </dl>
 *
 * @author Administrator
 */
@RestController
public class SendController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping(value = "/testSend", method = RequestMethod.GET)
    public String send3() throws UnsupportedEncodingException {
        String uuid = UUID.randomUUID().toString();
        CorrelationData correlationId = new CorrelationData(uuid);
        rabbitTemplate.convertAndSend(/*RabbitMQConfig.EXCHANGE,*/ RabbitMQConfig.ROUTINGKEY1, "哈哈key1"/*, correlationId*/);
        rabbitTemplate.convertAndSend(/*RabbitMQConfig.EXCHANGE,*/ RabbitMQConfig.ROUTINGKEY2, "哈哈"/*, correlationId*/);
        rabbitTemplate.convertAndSend(/*RabbitMQConfig.EXCHANGE,*/ RabbitMQConfig.ROUTINGKEY2, "哈哈2");
        rabbitTemplate.convertAndSend(/*RabbitMQConfig.EXCHANGE,*/ RabbitMQConfig.ROUTINGKEY2, "哈哈3");
        rabbitTemplate.convertAndSend(/*RabbitMQConfig.EXCHANGE,*/ RabbitMQConfig.ROUTINGKEY2, "哈哈4");
        rabbitTemplate.convertAndSend(/*RabbitMQConfig.EXCHANGE,*/ RabbitMQConfig.ROUTINGKEY2, "哈哈5");
        return uuid;
    }

}